package fatworm.parser.syntree;

import java.util.ArrayList;
import java.util.LinkedList;
/**
 * syntax tree node 
 * insert values into table
 */
public class InsertTableNode extends QueryNode{
	public String tableName;
	public ArrayList<ValueNode> values = null;
	public LinkedList<String> fieldlist = null;
	public InsertTableNode( String tableName , ArrayList<ValueNode> values ){
		this.tableName = tableName; this.values = values;
	}
	public InsertTableNode( String tableName,  LinkedList<String> fieldlist, ArrayList<ValueNode> values) {
		this.tableName = tableName; this.fieldlist = fieldlist; this.values = values;
	}
	public String toString() {
		String ans = "INSERT INTO "+ tableName+" VALUES(";
		for( java.util.Iterator<ValueNode> i = values.iterator(); i.hasNext();){
			ans += i.next() + (i.hasNext() ? ",": ")");
		}
		return ans;
	}
	public void accept(IQueryVisitor visitor) {
		visitor.visit( this );	
	}
}
